﻿using System;
using System.Collections.Generic;

namespace Bouyei.GeoCore.GeoParsers.Parser
{
    using Bouyei.GeoCore.Geometries;
    using Bouyei.GeoCore.GeoParsers.EsriJson;

    public class EsriJsonParser
    {
        private GeometryReader reader = null;
        private GeometryWriter writer = null;
        public GeoType GeometryType { get; private set; }

        public EsriJsonParser()
        {
            writer = new GeometryWriter();
        }

        public virtual Geometry FromReader(string esriJson)
        {
            using (reader = new GeometryReader(esriJson))
            {
                GeometryType = reader.GeometryType;
                return reader.Reader();
            }
        }

        public virtual string ToWriter(Geometry geometry)
        {
            return writer.ToWriter(geometry);
        }
    }
}
